package com.css.dzj.zfjg.modules.detail.mapper;

import com.css.dzj.zfjg.modules.detail.entity.Detail;
import com.css.dzj.zfjg.modules.detail.vo.Infopush;
import com.querydsl.core.QueryResults;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 信用详情Mapper
 * @author liyuan
 */
@Repository
public interface DetailMapper extends JpaRepository<Detail, String>, JpaSpecificationExecutor<Detail>,
        QuerydslPredicateExecutor<Detail> {

    @Query(value = "select Feedback_Org, count(Feedback_Org) as total from JG_XYJG_XYPGJGMX mx where Status = 2 group by Feedback_Org",
            nativeQuery = true)
    List<Object[]> list(Pageable pageable);

    @Query(value = "select count(*) as month from JG_XYJG_XYPGJGMX where Feedback_Time like CONCAT(:time,'%') and Feedback_Org = :provice and Status = 2",
            nativeQuery = true)
    String getMonthNumber(@Param("time") String time, @Param("provice") String provice);
}
